/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div
      id="explanation"
      class="explanation"
      style="color: rgb(85, 85, 85); background-color: rgb(243, 244, 244); width: 98%; height: 100%;"
    >
      <div class="bckopa-tips">
        <div class="title">
          <img src="@/static/images/handd.png" alt />
          <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
        </div>
        <ul>
          <li>展示商家服务相关信息的评分</li>
          <li>可根据店铺名称、用户名称进行搜索</li>
        </ul>
      </div>
      <span title="收起提示" id="explanationZoom" style="display: block;"></span>
    </div>
    <div class="mDiv">
      <div class="ftitle">
        <h3>满意度评价列表</h3>
        <h5>(共 {{totalCount}} 条记录)</h5>
      </div>
      <a href @click.prevent="refresh()" class="refresh-date">
        <div title="刷新数据" class="pReload">
          <i class="fa fa-refresh"></i>
        </div>
      </a>
      <div class="searchbox">
        <el-input class="searchinput" v-model="nickname" size="small" placeholder="用户名称" clearable />
        <el-input
          class="searchinput"
          v-model="storeName"
          size="small"
          placeholder="店铺名称"
          clearable
        />
        <el-button
          class="searchbtn"
          size="small"
          icon="el-icon-search"
          @click="currentPage = 1;getPage()"
        >搜索</el-button>
      </div>
    </div>
    <div class="tablebox" v-if="tableData">
      <el-table :data="tableData" ref="multipleTable" style="width: 100%;">
        <el-table-column label="用户名" prop="nickname" width="200"></el-table-column>
        <el-table-column label="订单号" prop="order_sn" width="200"></el-table-column>
        <el-table-column label="店铺名称" prop="store_name" width="200"></el-table-column>
        <el-table-column label="商品描述相符" prop="describe_score" width="150"></el-table-column>
        <el-table-column label="卖家服务态度" prop="seller_score" width="150"></el-table-column>
        <el-table-column label="物流发货速度" prop="logistics_score" width="150"></el-table-column>
        <el-table-column label="评论时间" prop="comment_time_desc" width="150"></el-table-column>
      </el-table>
      <el-pagination
        background
        class="paginationbox"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalCount"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { getStoreSatisfactionList } from "@/utils/api";
export default {
  data() {
    return {
      tableData: [],
      currentPage: this.$route.params.currentPage || 1,
      totalCount: 0,
      pageSize: 10,
      storeName: null,
      nickname: null
    };
  },
  created() {
    this.getPage();
  },
  methods: {
    handleSizeChange(e) {
      this.pageSize = e;
      this.getPage();
    },
    handleCurrentChange(e) {
      this.currentPage = e;
      this.getPage();
    },
    getPage() {
      var that = this;
      getStoreSatisfactionList({
        nickname: this.nickname,
        store_name: this.storeName,
        page: this.currentPage,
        size: this.pageSize
      }).then(function(res) {
        res.records.forEach(e => {
          e.describe_score = e.describe_score.toFixed(1);
          e.seller_score = e.seller_score.toFixed(1);
          e.logistics_score = e.logistics_score.toFixed(1);
        });
        that.tableData = res.records;
        that.totalCount = res.total;
      });
    },
    refresh() {
      this.getPage();
      this.$message({
        type: "success",
        message: "刷新成功！"
      });
    }
  }
};
</script>

<style scoped>
.searchinput {
  width: auto;
}
</style>
